From 53e4b2770095f853dfd4719da4390dbbf530ddeb Mon Sep 17 00:00:00 2001 From: "mwilli2@equilibrium.research.intel-research.net" Date: Fri, 9 Jul 2004 18:27:45 +0000 Subject: [PATCH] bitkeeper revision 1.1040.1.1 (40eee3a1eT0YAFxR2Vicy8vFSyHwSg) Support for Xen console ring output. --- .rootkeys | 2 ++ tools/python/xen/xend/XendClient.py | 9 ++++++++ tools/python/xen/xend/XendDmesg.py | 24 ++++++++++++++++++++ tools/python/xen/xend/server/SrvDmesg.py | 29 ++++++++++++++++++++++++ tools/python/xen/xend/server/SrvRoot.py | 1 + tools/python/xen/xm/main.py | 10 ++++++++ 6 files changed, 75 insertions(+) create mode 100644 tools/python/xen/xend/XendDmesg.py create mode 100644 tools/python/xen/xend/server/SrvDmesg.py diff --git a/.rootkeys b/.rootkeys index feb8ec1995..9a0453a229 100644 --- a/.rootkeys +++ b/.rootkeys @@ -252,6 +252,7 @@ 40c9c4688m3eqnC8fhLu1APm36VOVA tools/python/xen/xend/XendClient.py 40c9c468t6iIKTjwuYoe-UMCikDcOQ tools/python/xen/xend/XendConsole.py 40c9c468WnXs6eOUSff23IIGI4kMfQ tools/python/xen/xend/XendDB.py +40eee3a0sPO-WUu34uHUXOC7HliDGw tools/python/xen/xend/XendDmesg.py 40c9c468fSl3H3IypyT0ppkbb0ZT9A tools/python/xen/xend/XendDomain.py 40c9c468bbKq3uC7_fuNUkiMMjArdw tools/python/xen/xend/XendDomainConfig.py 40c9c4685ykq87_n1kVUbMr9flx9fg tools/python/xen/xend/XendDomainInfo.py @@ -267,6 +268,7 @@ 40c9c468woSmBByfeXA4o_jGf2gCgA tools/python/xen/xend/server/SrvDaemon.py 40c9c468kACsmkqjxBWKHRo071L26w tools/python/xen/xend/server/SrvDeviceDir.py 40c9c468EQZJVkCLds-OhesJVVyZbQ tools/python/xen/xend/server/SrvDir.py +40eee3a0m38EwYXfCSFIjWNwG6jx_A tools/python/xen/xend/server/SrvDmesg.py 40c9c468TyHZUq8sk0FF_vxM6Sozrg tools/python/xen/xend/server/SrvDomain.py 40c9c469WzajDjutou3X7FmL9hMf3g tools/python/xen/xend/server/SrvDomainDir.py 40c9c469-8mYEJJTAR6w_ClrJRAfwQ tools/python/xen/xend/server/SrvEventDir.py diff --git a/tools/python/xen/xend/XendClient.py b/tools/python/xen/xend/XendClient.py index 13dc3dbb1e..353d01ae71 100644 --- a/tools/python/xen/xend/XendClient.py +++ b/tools/python/xen/xend/XendClient.py @@ -79,6 +79,9 @@ def vneturl(location, root, id=''): def eventurl(location, root, id=''): return urljoin(location, root, 'event/', id) +def dmesgurl(location, root, id=''): + return urljoin(location, root, 'dmesg/', id) + def xend_request(url, method, data=None): urlinfo = urlparse.urlparse(url) (uproto, ulocation, upath, uparam, uquery, ufrag) = urlinfo @@ -160,6 +163,9 @@ class Xend: def eventurl(self, id=''): return eventurl(self.location, self.root, id) + def dmesgurl(self, id=''): + return dmesgurl(self.location, self.root, id) + def xend(self): return xend_get(urljoin(self.location, self.root)) @@ -281,6 +287,9 @@ class Xend: def xend_event_inject(self, sxpr): val = xend_call(self.eventurl(), {'op': 'inject', 'event': fileof(sxpr) }) + + def xend_dmesg(self): + return xend_get(self.dmesgurl()) def main(argv): diff --git a/tools/python/xen/xend/XendDmesg.py b/tools/python/xen/xend/XendDmesg.py new file mode 100644 index 0000000000..b344f50c0d --- /dev/null +++ b/tools/python/xen/xend/XendDmesg.py @@ -0,0 +1,24 @@ +# Copyright (C) 2004 Mike Wray + +"""Get dmesg output for this node. Very basic right now! +""" + +import os +import xen.lowlevel.xc + +class XendDmesg: + def __init__(self): + self.xc = xen.lowlevel.xc.new() + + def info(self): + return [ self.xc.readconsolering() ] + + +def instance(): + global inst + try: + inst + except: + inst = XendDmesg() + return inst + diff --git a/tools/python/xen/xend/server/SrvDmesg.py b/tools/python/xen/xend/server/SrvDmesg.py new file mode 100644 index 0000000000..cadfd692e8 --- /dev/null +++ b/tools/python/xen/xend/server/SrvDmesg.py @@ -0,0 +1,29 @@ +# Copyright (C) 2004 Mike Wray + +import os +from SrvDir import SrvDir +from xen.xend import sxp +from xen.xend import XendDmesg + +class SrvDmesg(SrvDir): + """Xen Dmesg output. + """ + + def __init__(self): + SrvDir.__init__(self) + self.xd = XendDmesg.instance() + + def render_GET(self, req): + if self.use_sxp(req): + req.setHeader("Content-Type", sxp.mime_type) + sxp.show(['dmesg'] + self.info(), out=req) + else: + req.write('') + req.write('
')
+            self.print_path(req)
+            req.write(self.info()[0])
+            req.write('
') + return '' + + def info(self): + return self.xd.info() diff --git a/tools/python/xen/xend/server/SrvRoot.py b/tools/python/xen/xend/server/SrvRoot.py index 8d38937b72..1211ff4bca 100644 --- a/tools/python/xen/xend/server/SrvRoot.py +++ b/tools/python/xen/xend/server/SrvRoot.py @@ -15,6 +15,7 @@ class SrvRoot(SrvDir): subdirs = [ ('node', 'SrvNode' ), ('domain', 'SrvDomainDir' ), + ('dmesg', 'SrvDmesg' ), ('console', 'SrvConsoleDir' ), ('event', 'SrvEventDir' ), ('device', 'SrvDeviceDir' ), diff --git a/tools/python/xen/xm/main.py b/tools/python/xen/xm/main.py index 3ab5d23cf7..91b7ad64d3 100644 --- a/tools/python/xen/xm/main.py +++ b/tools/python/xen/xm/main.py @@ -444,5 +444,15 @@ class ProgConsole(Prog): xm.prog(ProgConsole) +class ProgDmesg(Prog): + group = 'host' + name = "dmesg" + info = """Print Xen boot output.""" + + def main(self, args): + print server.xend_dmesg()[1] + +xm.prog(ProgDmesg) + def main(args): xm.main(args) -- 2.30.2